package com.cloud.observer.handler.successHandler;

import com.cloud.observer.AbstractInitScheduledInfoDingDingHandler;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.taobao.api.ApiException;

/**
 * @author: create by God of SJF
 * @version: v1.0
 * @description: com.cloud.observer.handler.successHandler
 * @date:2021/1/20
 */
public class TestScheduledSuccessHandler extends AbstractInitScheduledInfoDingDingHandler implements ISuccessDingHandler {


    @Override
    public void success() {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token="+token);
        OapiRobotSendRequest request = new OapiRobotSendRequest();
        request.setMsgtype("text");
        OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
        text.setContent("通知："+info.getName()+info.getRemark());
        request.setText(text);
        OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
        at.setIsAtAll(false);
        request.setAt(at);
        try {
            OapiRobotSendResponse response = client.execute(request);
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }
}
